﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;

public partial class Login : System.Web.UI.Page
{
    public bool flag = false;
    protected void Page_Load(object sender, EventArgs e)
    {
        txtusername.Focus();
    }
    protected void btnlogin_Click(object sender, EventArgs e)
    {
        ccJoin.ValidateCaptcha(txtcapcha.Text);
        if (!ccJoin.UserValidated)
        {
            flag = true;
            Label1.Text = "Mã bảo vệ chưa chính xác";
            txtcapcha.Focus();
            return;
        }
        else
        {
            if (MemberShip_ASP.Login(txtusername.Text, txtpassword.Text.Trim()))//new dang nhap thanh cong
            {
                Session["thoigian"] = DateTime.Now.Hour.ToString() + ":" + DateTime.Now.Minute.ToString();
                FormsAuthentication.RedirectFromLoginPage(txtusername.Text, false);
            }
            else
            {
                flag = false;
                Label1.Text = "Tên đăng nhập hoặc mật khẩu không đúng.";
            }
        }
    }
}